package com.pubinfo.passbook.api.controller.auth;

import com.alibaba.fastjson.JSON;
import com.pubinfo.passbook.api.eip.UserInfoService;
import com.pubinfo.passbook.common.entity.TRabbitmqPersonConvert;
import com.pubinfo.passbook.common.model.vo.base.JsonResult;
import com.pubinfo.passbook.common.model.vo.manage.RolePermissionVo;
import com.pubinfo.passbook.common.service.master.TRabbitmqPersonService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping(value = "persion")
@Api(tags = "4a人员管理")
@Slf4j

public class PersionController {
  
  @Autowired
  TRabbitmqPersonService personService;
  @Autowired
  UserInfoService infoService;
  
  @PostMapping("insertPersion")
  @ApiOperation(value = "新增人员")
  public JsonResult<Boolean> insertPersion(@RequestBody String user) {
    return JsonResult.success(personService.insertPersion(JSON.parseObject(user)));
  }
  
  @DeleteMapping("delete")
  @ApiOperation(value = "删除人员")
  public JsonResult<Boolean> removePersion(Integer id) {
    return JsonResult.success(personService.removePerson(id));
  }
  
  @PostMapping("getPersonMenu")
  @ApiModelProperty("获取用户菜单权限")
  public JsonResult<List<RolePermissionVo>> getPersonMenu(String token) {
  
    TRabbitmqPersonConvert current4AUserInfo = infoService.getCurrent4AUserInfo(token);
    return JsonResult.success(personService.getPersonMenu(current4AUserInfo));
  }
}
